package org.study.id.baidu.service;

import com.xfvape.uid.UidGenerator;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 类的描述
 *
 * @author Administrator
 * @date 2021-05-27
 */
@Slf4j
@Service
public class WorkerNodeServiceImpl implements WorkerNodeService {
    @Resource(name = "defaultUidGenerator")
    //@Resource(name = "cachedUidGenerator")
    private UidGenerator uidGenerator;

    @Override
    public long genUid() {
        long uid = uidGenerator.getUID();
        log.info("生成的uid：{}", uid);
        String parseUid = uidGenerator.parseUID(uid);
        log.info("uid解析结果：{}", parseUid);
        return uid;
    }

    @Override
    public String parseUid(long uid) {
        String parseUid = uidGenerator.parseUID(uid);
        log.info("uid：{}，解析结果：{}", uid, parseUid);
        return parseUid;
    }
}
